package com.yc.edu.controller;

import cn.hutool.log.Log;
import com.yc.edu.pojo.Result;
import com.yc.edu.service.CourseService;
import com.yc.edu.utils.PageUtils;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author YC
 * @version 1.0
 */
@RestController
@Slf4j
@RequestMapping("/course")
public class CourseController {
    @Resource
    CourseService courseService;

    /**
     * 查询课程 keyword
     * @param params
     * @return
     */
    @GetMapping("/info")
    public Result info(@RequestParam Map<String, Object> params) {
        log.info("查看params的值{}",params);
        PageUtils page = courseService.queryInfo(params);
        return Result.success(page);
    }

    @GetMapping("/name/{id}")
    public Result recommend(@PathVariable String id) {
        System.out.println(id);
        return Result.success(courseService.getCoursesByUserId(id));
    }
}
